/**
 * @File name: os/config/os_api.h
 * @Synopsis:
 * @Author: xing.dai@aliyun.com
 * @Version: 0.0.1
 * @Date: 2018-08-13 21:27
 */

#ifndef __OS_API_H__
#define __OS_API_H__

#include "os.h"

/**
 * How to use critical section?
 * 1. os_critial_alloc();	// alloc cpu_sr variable.
 * 2. os_enter_critical();
 * 3. Your critical code.
 * 4. os_exit_critical();
 */
#define os_critial_alloc()	CPU_SR_ALLOC()
#define os_enter_critical()			\
			do {					\
				os_critical_cnt++;	\
				OS_CRITICAL_ENTER();\
			}while(0)

#define os_exit_critical()		\
			do {				\
				if (-- os_critical_cnt == 0)	\
					OS_CRITICAL_EXIT();			\
			}while(0)

extern unsigned int os_critical_cnt;

/* Public function. */
void sleep_tick(uint32 tick);
void sleep_ms(uint32 ms);
#endif

